'use strict';

stareal
    .controller("CityController", function ($scope,$interval,$document, $stateParams, $api, $sce, base64, $state, $alert,localStorageService,$timeout,$location, $anchorScroll) {
        $api.get("app/city/list", {},true).then(function (ret){
            $scope.citys=ret.data;
           // for(var i=0;i<$scope.citys.length;i++){
           //     if($scope.citys[i].sorts)
           // }
        });
        $scope.sortscity=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','R','S','T','U','V','W','X','Y','Z'];
        $scope.gotoBottom = function(id) {
           //   console.log(id);
            // 将location.hash的值设置为
            // 你想要滚动到的元素的id
            $location.hash(id);

            // 调用 $anchorScroll()
            $anchorScroll();
        };
        //定位城市
       $scope.currentCIty=   localStorageService.get('cityname');
        $scope.currentCItyId=   localStorageService.get('cityid');


        //切换城市
        $scope.switchCity=function(id,name){
            localStorageService.set('cityid',id);
            localStorageService.set('cityname',name);
          $state.go('main.index',{},true);
        }

    });